﻿using System.Collections.Generic;
using Firefly.Framework.Windows;
using Firefly.Framework.Windows.ContentReaders;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content.Pipeline.Serialization.Compiler;

namespace Firefly.ContentPipeline.Windows
{
    [ContentTypeWriter]
    public class CursorCollectionContentWriter : ContentTypeWriter<CursorCollection>
    {
        protected override void Write(ContentWriter output, CursorCollection value)
        {
            WriteCursorList(output, value);
        }

        public override string GetRuntimeReader(TargetPlatform targetPlatform)
        {
            return typeof(CursorCollectionContentReader).AssemblyQualifiedName;
        }

        internal static void WriteCursorList(ContentWriter output, CursorCollection value)
        {
            output.Write(value.Count);

            foreach (KeyValuePair<string, Cursor> item in value)
            {
                output.Write(item.Key);
                output.WriteObject<Cursor>(item.Value);
            }
        }
    }
}
